# $Id$
# Maintainer: Christian Hesse <mail@eworm.de>
# Contributor: Rustam Tsurik <rustam.tsurik@gmail.com>
# Contributor: Nico Suarez <nicodoggie@gmail.com>

pkgname=galera
pkgver=25.3.21
pkgrel=1
pkgdesc='write set replication (WSREP) provider for MariaDB cluster'
arch=('i686' 'x86_64')
license=('GPL2' 'custom:OpenSSL Linking Exception')
depends=('mariadb' 'openssl')
makedepends=('asio' 'check' 'scons')
optdepends=('rsync: transfer database state to a newly joined node with rsync')
url='http://www.codership.com/'
options=('!libtool')
validpgpkeys=('44B7345738EBDE52594DAD80D669017EBC19DDBA') # Codership Oy <info@galeracluster.com>
source=("http://releases.galeracluster.com/${pkgname}-${pkgver#25.}/source/${pkgname}-3-${pkgver}.tar.gz"{,.asc}
        '0001-fix-compilation-with-GCC-7.1.1-implicit-fallthrough.patch')
sha256sums=('1035b8a62cd3695ab2af8c8f1be785942d68a07123bb9bc051b51fc4b5735904'
            'SKIP'
            'bf6f395f66ba87157f0dd0f6627528808699e278ac0223eb64cd86cc856d024c')

prepare() {
  cd "${pkgname}-3-${pkgver}"

  # fix compilation with GCC 7.1.1 (implicit-fallthrough)
  patch -Np1 < "${srcdir}"/0001-fix-compilation-with-GCC-7.1.1-implicit-fallthrough.patch
}

build(){
  cd "${pkgname}-3-${pkgver}"

  scons
}

package(){
  cd "${pkgname}-3-${pkgver}"

  install -D -m0755 libgalera_smm.so "${pkgdir}"/usr/lib/galera/libgalera_smm.so
  ln -s galera/libgalera_smm.so "${pkgdir}"/usr/lib/libgalera_smm.so

  install -D -m0755 garb/garbd "${pkgdir}"/usr/bin/garbd

  install -D -m0644 scripts/packages/README "${pkgdir}"/usr/share/doc/galera/README
  install -D -m0644 scripts/packages/README-MySQL "${pkgdir}"/usr/share/doc/galera/README-MySQL
  install -D -m0644 scripts/mysql/README "${pkgdir}"/usr/share/doc/galera/mysql/README
  install -D -m0644 COPYING "${pkgdir}"/usr/share/doc/galera/COPYING
}

